<form id="addOrUpdateForm" lay-filter="addOrUpdateForm" class="layui-form model-form">

  <input name="id" type="hidden"/>
  <div class="layui-form-item">
    <label class="layui-form-label layui-form-required">分配人员数量</label>
    <div class="layui-input-block">
      <input name="renyuan" class="layui-input" placeholder="请输入人员数量" lay-verType="tips" lay-verify="required" required/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">地区:</label>
    <div class="layui-input-block">
      <select name="ryplace">
            <option value="">--请选择地区--</option>
        <option value="南岗区">南岗区人员负责人</option>
        <option value="香坊区">香坊区人员负责人</option>
        <option value="道里区">道里区人员负责人</option>
        <option value="道外区">道外区人员负责人</option>
        <option value="松北区">松北区人员负责人</option>
        <option value="呼兰区">呼兰区人员负责人</option>
        <option value="平房区">平房区人员负责人</option>
        <option value="双城区">双城区人员负责人</option>
        <option value="阿城区">阿城区人员负责人</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">分配物资情况</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入分配物资情况" class="layui-textarea" name="wuzi"></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">应急上报种类</label>
    <div class="layui-input-block">
      <div id="reportspeciesId"></div>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">发生情况</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入发生情况" class="layui-textarea" name="occurrence" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">事件时间</label>
    <div class="layui-input-block">
      <input type="text" name="eventtime" id="eventtimeId" placeholder="请选择事件时间" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">地点</label>
    <div class="layui-input-block">
      <input name="place" class="layui-input" placeholder="请输入地点" lay-verType="tips" />
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">单位</label>
    <div class="layui-input-block">
      <input name="unit" class="layui-input" placeholder="请输入单位" lay-verType="tips" />
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">简要经过</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入简要经过" class="layui-textarea" name="afterbriefly" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">伤亡人数</label>
    <div class="layui-input-block">
      <input name="casualty" type="number" class="layui-input" placeholder="请输入伤亡人数" lay-verType="tips"/>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">直接经济损失（估算）</label>
    <div class="layui-input-block">
      <input name="economicloss" class="layui-input" placeholder="请输入直接经济损失（估算）" lay-verType="tips"/>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">发生原因（初步判断）</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入发生原因（初步判断）" class="layui-textarea" name="reason" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">先期处置措施</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入先期处置措施" class="layui-textarea" name="measure" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">下一步处置措施</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入下一步处置措施" class="layui-textarea" name="nextmeasure" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">事故控制情况</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入事故控制情况" class="layui-textarea" name="controlaccident" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">未来走势预测</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入未来走势预测" class="layui-textarea" name="forecastfuture" ></textarea>
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">
      报送单位</label>
    <div class="layui-input-block">
      <input name="sendunit" class="layui-input" placeholder="请输入报送单位" lay-verType="tips" />
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">签发人</label>
    <div class="layui-input-block">
      <input name="signer" class="layui-input" placeholder="请输入签发人" lay-verType="tips" />
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">联系人</label>
    <div class="layui-input-block">
      <input name="contact" class="layui-input" placeholder="请输入联系人" lay-verType="tips" />
    </div>
  </div>

  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label layui-form-required">联系电话</label>
    <div class="layui-input-block">
      <input name="phone" class="layui-input" placeholder="请输入联系电话" lay-verType="tips" />
    </div>
  </div>


  <div class="layui-form-item text-right">
    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    <button class="layui-btn" lay-filter="formSubmitBtn" lay-submit>保存</button>
  </div>
</form>

<script>
  layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var admin = layui.admin;
    var xnUtil = layui.xnUtil;
    var xmSelect = layui.xmSelect;
    var laydate = layui.laydate;

    var reportspeciesRenderIns = xmSelect.render({
      el: '#reportspeciesId',
      name: 'reportspecies',
      data: xnUtil.getDictDataByDictTypeCode('emergencyreporttypes', null),
      layVerify: 'required',
      layVerType: 'tips',
      radio: true,
      clickClose: true,
      model: { icon:'hidden', label: { type: 'text' }},
      prop: {
        name: 'name',
        value: 'code'
      },
      tips: '请选择应急上报种类'
    }, {async: false});

    laydate.render({
      elem: '#eventtimeId'
    });

    var editData = admin.getLayerData('#addOrUpdateForm').data;
    if(editData !== null && editData !== undefined) {
      form.val('addOrUpdateForm', editData);
      // 下拉赋值
      reportspeciesRenderIns.setValue([editData.reportspecies]);

    }

    /**
     * 表单提交事件
     */
    form.on('submit(formSubmitBtn)', function (data) {
      layer.load(2);

      var url = editData ? getProjectUrl() + 'report/db' : getProjectUrl() + 'report/add';
      admin.req(url, JSON.stringify(data.field), function(res){
        layer.msg(res.message, {icon: 1, time: 1000}, function () {
          admin.putLayerData('formOk', true, '#addOrUpdateForm');
          admin.closeDialog('#addOrUpdateForm');
        });
      }, 'post');
      return false;
    });
  });
</script>
</body>
</html>
